<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>范例</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="fdf.constants.html">预定义常量</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.fdf.html">FDF 函数</a></div>
 <div class="up"><a href="book.fdf.html">FDF</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="fdf.examples" class="chapter">
 <h1>范例</h1>

 <p class="para">
  The following examples shows just the evaluation of form data.
  <div class="example" id="example-3388">
   <p><strong>Example #1 Evaluating a FDF document</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Open&nbsp;fdf&nbsp;from&nbsp;input&nbsp;string&nbsp;provided&nbsp;by&nbsp;the&nbsp;extension<br />//&nbsp;The&nbsp;pdf&nbsp;form&nbsp;contained&nbsp;several&nbsp;input&nbsp;text&nbsp;fields&nbsp;with&nbsp;the&nbsp;names<br />//&nbsp;volume,&nbsp;date,&nbsp;comment,&nbsp;publisher,&nbsp;preparer,&nbsp;and&nbsp;two&nbsp;checkboxes<br />//&nbsp;show_publisher&nbsp;and&nbsp;show_preparer.<br /></span><span style="color: #0000BB">$fdf&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fdf_open_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$HTTP_FDF_DATA</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$volume&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fdf_get_value</span><span style="color: #007700">(</span><span style="color: #0000BB">$fdf</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"volume"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;volume&nbsp;field&nbsp;has&nbsp;the&nbsp;value&nbsp;'&lt;b&gt;</span><span style="color: #0000BB">$volume</span><span style="color: #DD0000">&lt;/b&gt;'&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$date&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fdf_get_value</span><span style="color: #007700">(</span><span style="color: #0000BB">$fdf</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"date"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;date&nbsp;field&nbsp;has&nbsp;the&nbsp;value&nbsp;'&lt;b&gt;</span><span style="color: #0000BB">$date</span><span style="color: #DD0000">&lt;/b&gt;'&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$comment&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fdf_get_value</span><span style="color: #007700">(</span><span style="color: #0000BB">$fdf</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"comment"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;comment&nbsp;field&nbsp;has&nbsp;the&nbsp;value&nbsp;'&lt;b&gt;</span><span style="color: #0000BB">$comment</span><span style="color: #DD0000">&lt;/b&gt;'&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br /><br />if&nbsp;(</span><span style="color: #0000BB">fdf_get_value</span><span style="color: #007700">(</span><span style="color: #0000BB">$fdf</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"show_publisher"</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #DD0000">"On"</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$publisher&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fdf_get_value</span><span style="color: #007700">(</span><span style="color: #0000BB">$fdf</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"publisher"</span><span style="color: #007700">);<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;publisher&nbsp;field&nbsp;has&nbsp;the&nbsp;value&nbsp;'&lt;b&gt;</span><span style="color: #0000BB">$publisher</span><span style="color: #DD0000">&lt;/b&gt;'&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br />}&nbsp;else<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Publisher&nbsp;shall&nbsp;not&nbsp;be&nbsp;shown.&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br /><br />if&nbsp;(</span><span style="color: #0000BB">fdf_get_value</span><span style="color: #007700">(</span><span style="color: #0000BB">$fdf</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"show_preparer"</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #DD0000">"On"</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$preparer&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fdf_get_value</span><span style="color: #007700">(</span><span style="color: #0000BB">$fdf</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"preparer"</span><span style="color: #007700">);<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;preparer&nbsp;field&nbsp;has&nbsp;the&nbsp;value&nbsp;'&lt;b&gt;</span><span style="color: #0000BB">$preparer</span><span style="color: #DD0000">&lt;/b&gt;'&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br />}&nbsp;else<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Preparer&nbsp;shall&nbsp;not&nbsp;be&nbsp;shown.&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">fdf_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$fdf</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

  </div>
 </p>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="fdf.constants.html">预定义常量</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.fdf.html">FDF 函数</a></div>
 <div class="up"><a href="book.fdf.html">FDF</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
